package
{
	import com.greensock.layout.ScaleMode;

	public class VideoGridFlashVars
	{
		
		/**
		 * Default value for <code>rows</code>
		 * @see #rows
		 */
		public static const DEFAULT_ROWS:int = 3;
		
		/**
		 * Default value for <code>columns</code>
		 * @see #columns
		 */
		public static const DEFAULT_COLUMNS:int = 3;
		
		/**
		 * Default value for <code>width</code>
		 * @see #width
		 */
		public static const DEFAULT_WIDTH:Number = 160;
		
		/**
		 * Default value for <code>height</code>
		 * @see #height
		 */
		public static const DEFAULT_HEIGHT:Number = 90;
		
		/**
		 * Default value for <code>distance</code>
		 * @see #distance
		 */
		public static const DEFAULT_DISTANCE:Number = 10;
				
		
		/**
		 * Default value for <code>autoPlay</code>
		 * @see #autoPlay
		 */
		public static const DEFAULT_AUTOPLAY:Boolean = false;
		
		public static const DEFAULT_VIDEO_BUFFERTIME:Number = 3;
				
		
		
		
		/**
		 * @private
		 * Holds the <code>loaderInfo.parameters</code> of the main swf.
		 */ 
		private var params:Object; 
		
		/**
		 * Grants access to values specified in the embed flashvars
		 */
		public function VideoGridFlashVars(params:Object)
		{
			this.params = params;
		}
		 
		/**
		 * Number of columns for the grid
		 */
		public function get gridColumns():int
		{
			return int(params['gridColumns']) || DEFAULT_COLUMNS;	
		}
		
		
		public function get gridAutoCenter():Boolean
		{
			return params['gridAutoCenter'] === 'true';
		}
		
		
		public function get gridOffsetX():Number
		{
			return Number(params['gridOffsetX']) || 0;
		}
		public function get gridOffsetY():Number
		{
			return Number(params['gridOffsetY']) || 0;
		}
		
		/**
		 * Width for each individual grid item
		 */
		public function get itemWidth():Number
		{
			return Number(params['itemWidth']) || DEFAULT_WIDTH;	
		}
		
		/**
		 * Height for each individual grid item
		 */
		public function get itemHeight():Number
		{
			return Number(params['itemHeight']) || DEFAULT_HEIGHT;	
		}
		
		/**
		 * Distance between grid items
		 */
		public function get itemDistance():Number
		{
			return Number(params['itemDistance']) || DEFAULT_DISTANCE;	
		}
		
		/**
		 * If set to true, playback of each video can be toggled by clicking on it
		 */
		public function get itemToggleOnClick():Boolean
		{
			return params['itemToggleOnClick'] === 'true';
		}
		
		public function get videoBufferTime():Number
		{
			return Number(params['videoBufferTime']) || DEFAULT_VIDEO_BUFFERTIME;
			
		}
		
		public function get videoAutoPlay():Boolean
		{
			return params['videoAutoPlay'] === 'true';
		}
		
		/**
		 * Scalemode for grid videos.
		 * @see com.greensock.layout.ScaleMode
		 */
		public function get videoScaleMode():String
		{
			return params['videoScaleMode'] || ScaleMode.PROPORTIONAL_INSIDE;
		}
		
		/**
		 * Scale factor for each video (within the mask with the dimensions itemWidth, itemHeight)
		 */
		public function get itemScale():Number
		{
			return Number(params['itemScale']) || 1;
		}
		
		/**
		 * X-Position offset for each item within its mask.
		 */
		public function get itemOffsetX():Number
		{
			return Number(params['itemOffsetX']) || 0;
		}
		
		/**
		 * Y-Position offset for each item within its mask.
		 */
		public function get itemOffsetY():Number
		{
			return Number(params['itemOffsetY']) || 0;
		}
		
		
		/**
		 * Whether all videos should start playing once their buffers are full.
		 */
		public function get syncStart():Boolean
		{
			return params['syncStart'] === 'true';
		}
		
		/**
		 * The background color of each video
		 */
		public function get bgColor():uint
		{
			return uint(params['bgColor']) || 0x000000;
		}
		/**
		 * The background alpha of each video
		 */
		public function get bgAlpha():Number
		{
			return Number(params['bgAlpha']) || 1;
		}
		
		public function get debug():Boolean
		{
			return params['debug'] === 'true';
		}
		 
		 
		
		/**
		 * An array containing urls to video files
		 */
		public function get files():Array
		{
			if (!params['files']) {
				return null;
			}
			return JSON.parse(params['files']) as Array;
		}
		
	}
}